Option Explicit
Dim strFolderToSearch, objFSO, objRootFolder, objFolder, colSubfolders, strOutput
dim foldername
dim FoldersProcessed

rem //--- Get this folder  ----


If Wscript.Arguments.Count > 0 Then
    	Set objFSO = CreateObject("Scripting.FileSystemObject")
	strFolderToSearch = objFSO.GetAbsolutePathName(".")
	set objRootFolder = objFSO.GetFolder(Wscript.Arguments(0))
	rem strFolderToSearch = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))         
	Call ProcessFolder (objRootFolder, "release") 
	Call ProcessFolder (objRootFolder, "Drop")
	rem //MsgBox "Processed the following : " & vbCr & vbLf  & FoldersProcessed
 
End If



 rem ///   Function to iteratre down subfolder tree and ensure all relase folders are not readonly
Sub ProcessFolder(AFolder, foldernameToProcess)
	Dim SubFolder
	Dim AFile
	dim foldername
	foldername = AFolder.ShortName 
	
	rem MsgBox foldername & " foldername=" & foldername
	rem -----Process files ------
	rem ---- (1 is the value of the ReadOnly attribute) ---
	if(StrComp(foldername, foldernameToProcess, vbTextCompare) = 0) then
		FoldersProcessed = FoldersProcessed & AFolder   & vbCr & vbLf
		For Each AFile In AFolder.Files
			AFile.Attributes = AFile.Attributes And Not 1
		Next
	End if
	
	rem ----Ieterate sub Folder ------
	For Each SubFolder In AFolder.SubFolders
		if(StrComp(foldername, foldernameToProcess, vbTextCompare) = 0) then
			SubFolder.Attributes = SubFolder.Attributes And Not 1			
		End if
		ProcessFolder SubFolder ,foldernameToProcess
	Next
End Sub

Function IterateDirs(strFolderToSearch)

	REM --- get folder name  AND CHECK IF ITS RELEASE
	Set objFolder = objFSO.GetFolder(strFolderToSearch)
	foldername = objFolder.ShortName 

	if(StrComp(foldername, "release", vbTextCompare) = 0) then
		MsgBox "Release FOUND strFolderToSearch=" & strFolderToSearch
	else
		MsgBox "Relase NOT FOUND strFolderToSearch=" & strFolderToSearch
	End if
	
	
	rem  Check Subfolders
	Set objRootFolder = objFSO.GetFolder(strFolderToSearch)
	Set colSubfolders = objRootFolder.SubFolders
	For Each objFolder in colSubfolders		
		 IterateDirs(objFolder)
	Next


End Function 